//
//  EFBFavoritesView.m
//  Pods
//
//  Created by E.F.B on 15-5-11.
//
//

#import "EFBFavoritesView.h"

@interface EFBFavoritesView ()

@property (readonly, nonatomic) NSArray * buttonArray;

@end

@implementation EFBFavoritesView
- (void)dealloc
{
    [_buttonArray release];
    [_typeLabel release];
    [_spacePageControl release];
    [super dealloc];
}

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        
        CGRect rect = CGRectMake(0, 5, 80, 30);

        _typeLabel = [[UILabel alloc] initWithFrame:rect];
        _typeLabel.textAlignment = NSTextAlignmentCenter;
        _typeLabel.textColor = [UIColor lightGrayColor];
        _typeLabel.text = @"";
        _typeLabel.font = [UIFont boldSystemFontOfSize:14.0f];
        [self addSubview:_typeLabel];

        rect.origin.y = 20;
        _spacePageControl = [[SMPageControl alloc] initWithFrame:rect];
        _PageCount = 0;
        _spacePageControl.numberOfPages = self.PageCount;
        [_spacePageControl setPageIndicatorImage:[UIImage imageNamed:@"pageDot"]];
        [_spacePageControl setCurrentPageIndicatorImage:[UIImage imageNamed:@"currentPageDot"]];
        
//        _spacePageControl.indicatorMargin = 4.0f;
//        _spacePageControl.indicatorDiameter = 4.0f;
        [self addSubview:_spacePageControl];
//        _spacePageControl.backgroundColor = [UIColor redColor];
        _spacePageControl.currentPage = -1;
        [_spacePageControl updateCurrentPageDisplay];
    }
    return self;
}

- (void)updatePageDisplay:(NSString *)s
{
    if ([s isEqualToString:@"YES"]) {
        self.PageCount ++ ;
    }else{
        self.PageCount -- ;
    }
    NSLog(@" self.pageCount  === %d   ",self.PageCount);
    self.spacePageControl.numberOfPages = self.PageCount;
    CGSize size = [self.spacePageControl sizeForNumberOfPages:self.PageCount];
    if (size.width < 50) {
        size.width = 50;
    }
    
    CGRect rect = self.spacePageControl.frame;
    rect.size = size;
    CGRect rect1 = self.typeLabel.frame;
    rect1.size = size;
    self.spacePageControl.frame = rect;
    self.typeLabel.frame = rect1;
    
}

- (void)reloadCountView:(NSString *)s
{
    self.PageCount = [s integerValue];
    self.spacePageControl.numberOfPages = self.PageCount;
    CGSize size = [self.spacePageControl sizeForNumberOfPages:self.PageCount];
    if (size.width < 50) {
        size.width = 50;
    }
    CGRect rect = self.spacePageControl.frame;
    rect.size = size;
    CGRect rect1 = self.typeLabel.frame;
    rect1.size = size;
    self.spacePageControl.frame = rect;
    self.typeLabel.frame = rect1;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
